package com.pubinfo.passbook.engine.cell.logic.medicine;

import com.pubinfo.passbook.common.model.constant.StaffStatusEnum;
import com.pubinfo.passbook.common.model.dto.witeoff.MedicineOnJobOrRetireDTO;
import com.pubinfo.passbook.common.model.ruler.PayInformation;
import com.pubinfo.passbook.common.service.dubbo.DubboService;
import com.pubinfo.passbook.common.utils.ApplicationContextUilts;

import java.math.BigDecimal;
import java.util.List;

/**
 * 是否在职
 *
 * @author zhouch
 * @date 2022/1/10 10:33
 */
public class JobWhetherUnit extends MedicineLogicUnit {


    DubboService dubboService;

    public JobWhetherUnit() {
        dubboService = ApplicationContextUilts.getBean(DubboService.class);
    }

    @Override
    public Boolean then(MedicineOnJobOrRetireDTO data, BigDecimal result) {
        List<PayInformation> payInformations = cache.getPayInformationData();
        // 报账人的身份证号
        String idNo = payInformations.get(0).getPayerPartyCode();
        String statusName = dubboService.getPersonsDetailByStatus(idNo);
        Integer status = StaffStatusEnum.getEnumByStatus(statusName).getCode();

        return status.equals(1);
    }


    @Override
    public String getName() {
        return "是否在在职";
    }
}
